package com.xyht.sca_s.student_manage_system.modules.websocket.entity;

import com.xyht.sca_s.student_manage_system.modules.websocket.myEnum.WebsocketResultEnum;
import lombok.Data;

@Data
public class WebsocketResult<T> {
    private String socket_name;
    private String socket_type;
    private String socket_msg;
    private Object socket_data;

    public WebsocketResult(String socket_name,String socket_type,String socket_msg,T socket_data){
        this.socket_name = socket_name;
        this.socket_type = socket_type;
        this.socket_msg = socket_msg;
        this.socket_data = socket_data;
    }

    public WebsocketResult(String socket_name,String socket_type,String socket_msg){
        this.socket_name = socket_name;
        this.socket_type = socket_type;
        this.socket_msg = socket_msg;
    }

    public static <T> WebsocketResult<T> success(WebsocketResultEnum websocketResultEnum,T data) {
        return new WebsocketResult<T>(websocketResultEnum.getSocket_name(),
                websocketResultEnum.getSocket_type(),
                websocketResultEnum.getSocket_msg(),
                data);
    }
    public static <T> WebsocketResult<T> success(WebsocketResultEnum websocketResultEnum) {
        return new WebsocketResult<T>(websocketResultEnum.getSocket_name(),
                websocketResultEnum.getSocket_type(),
                websocketResultEnum.getSocket_msg());
    }

    public static <T> WebsocketResult<T> success() {
        return new WebsocketResult<T>(WebsocketResultEnum.SUCCESS.getSocket_name(),
                WebsocketResultEnum.SUCCESS.getSocket_type(),
                WebsocketResultEnum.SUCCESS.getSocket_msg()
                );
    }

    /**
     * 失败返回结果
     *
     */
    public static <T> WebsocketResult<T> failed(WebsocketResultEnum websocketResultEnum) {
        return new WebsocketResult<T>(websocketResultEnum.getSocket_name(),
                websocketResultEnum.getSocket_type(),
                websocketResultEnum.getSocket_msg());
    }
}
